import App from './App'

// 导入全局
import '@/utils/utils'
import { createPinia } from "pinia"
// import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import { createPersistedState } from 'pinia-plugin-persistedstate'
// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
  const app = createSSRApp(App)
  const pinia = createPinia()
  // pinia.use(piniaPluginPersistedstate)
  pinia.use(createPersistedState({
    key: (id) => `__persisted__${id}`,
    storage: {
      setItem: (key, value) => {
        uni.setStorageSync(key, value)
      },
      getItem: (key) => {
        return uni.getStorageSync(key)
      }
    }
  }))
  app.use(pinia)
  return {
    app,
  }
}
// #endif